<?php
/**
 * 学生表单信息验证存入数据库中
 */
include '../util/DBUtil.php';
include '../util/PromptAction.php';

//获取学生信息添加修改表单值
$id = $_POST['id'];
$stuNo = $_POST['stuNo'];
$name = $_POST['name'];
$gender = $_POST['gender'];
$grade = $_POST['grade'];
//echo 'id='.$id;
//echo 'stuNo='.$stuNo;
//echo 'name='.$name;
//echo 'gender='.$gender;
//echo 'grade='.$grade;
//设置sql语句
$sql = "";
$db = new DBUtil();
$params = array();
if ($id!=""){//修改信息
    $sql = "update tb_student set name=?,gender=?,grade_id=? where id=? ";
    $params=array($name,$gender,$grade,$id);
//    print_r('sql='.$sql);
//    print_r('params='.$params[0]);
}else{
    $sql = "insert into tb_student(student_no,name,gender,grade_id) values(?,?,?,?)";
    $params = array($stuNo,$name,$gender,$grade);
}

$statue = $db->update($sql,$params);
showStatue($statue);
echo "<script>window.open('../view/student.php','info')</script>";